package Vistas;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import Modelos.Cliente;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class FrmCliente extends javax.swing.JFrame {
	private JLabel LblNombre;
	private JTextField txtNombre;
	private JButton BtnSalir;
	private JButton BtnCancelar;
	private JButton BtnGuardar;
	private JTextField TxtDireccion;
	private JLabel LblDireccion;
	private JTextField TxtTelf;
	private JLabel LblTelefono;
	private JTextField TxtRazon;
	private JLabel LblRazonSocial;
	private JTextField txtcedulaorif;
	private JLabel Lblcedulaorif;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	
	public FrmCliente() {
		super();
		initGUI();
		txtcedulaorif.setEnabled(false);
	}
	
	public void addListener(ActionListener actionlistener){
		BtnCancelar.addActionListener(actionlistener);
		BtnGuardar.addActionListener(actionlistener);
		BtnSalir.addActionListener(actionlistener);
	}
	
	public void MensajeConfirmacion(){
		JOptionPane.showMessageDialog(rootPane,"Operacion Completada");
	}
	
	public void Cancelar(){
		txtNombre.setText("");
		TxtDireccion.setText("");
		TxtRazon.setText("");
		TxtTelf.setText("");
	}
	
	public boolean validado(){
		return !txtcedulaorif.getText().equals("") && !txtNombre.getText().equals("") && !TxtDireccion.getText().equals("") && !TxtRazon.getText().equals("") && !TxtTelf.getText().equals("");
	}
	
	public void MsgError(){
		JOptionPane.showMessageDialog(rootPane,"Datos Invalidos");
	}
	
	public void AsignarCedulaRif(String valor){
		txtcedulaorif.setText(valor);
	}
	public void Salir(){
		this.dispose();
	}
	
	public Cliente cliente(){
		return new Cliente(txtcedulaorif.getText(),TxtRazon.getText(), TxtDireccion.getText(), TxtTelf.getText(), txtNombre.getText());
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				LblNombre = new JLabel();
				getContentPane().add(LblNombre);
				LblNombre.setText("Nombre");
				LblNombre.setBounds(18, 19, 75, 20);
			}
			{
				txtNombre = new JTextField();
				getContentPane().add(txtNombre);
				txtNombre.setBounds(93, 19, 119, 21);
			}
			{
				Lblcedulaorif = new JLabel();
				getContentPane().add(Lblcedulaorif);
				Lblcedulaorif.setText("Cedula/Rif");
				Lblcedulaorif.setBounds(18, 62, 75, 14);
			}
			{
				txtcedulaorif = new JTextField();
				getContentPane().add(txtcedulaorif);
				txtcedulaorif.setBounds(93, 59, 119, 21);
			}
			{
				LblRazonSocial = new JLabel();
				getContentPane().add(LblRazonSocial);
				LblRazonSocial.setText("RazonSocial");
				LblRazonSocial.setBounds(18, 104, 75, 14);
			}
			{
				TxtRazon = new JTextField();
				getContentPane().add(TxtRazon);
				TxtRazon.setBounds(93, 101, 119, 21);
			}
			{
				LblTelefono = new JLabel();
				getContentPane().add(LblTelefono);
				LblTelefono.setText("Telefono");
				LblTelefono.setBounds(18, 146, 75, 14);
			}
			{
				TxtTelf = new JTextField();
				getContentPane().add(TxtTelf);
				TxtTelf.setBounds(93, 143, 119, 21);
			}
			{
				LblDireccion = new JLabel();
				getContentPane().add(LblDireccion);
				LblDireccion.setText("Direccion");
				LblDireccion.setBounds(18, 190, 75, 14);
			}
			{
				TxtDireccion = new JTextField();
				getContentPane().add(TxtDireccion);
				TxtDireccion.setBounds(93, 187, 239, 23);
			}
			{
				BtnGuardar = new JButton();
				getContentPane().add(BtnGuardar);
				BtnGuardar.setText("Guardar");
				BtnGuardar.setBounds(18, 226, 86, 21);
			}
			{
				BtnCancelar = new JButton();
				getContentPane().add(BtnCancelar);
				BtnCancelar.setText("Cancelar");
				BtnCancelar.setBounds(109, 226, 90, 21);
			}
			{
				BtnSalir = new JButton();
				getContentPane().add(BtnSalir);
				BtnSalir.setText("Salir");
				BtnSalir.setBounds(292, 226, 62, 21);
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
